package myapplication;

import android.support.multidex.MultiDexApplication;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Map;

import android_serialport_api.SerialPort;
import constants.Constants;
import crashhandler.CrashHandler;
import netframe.NetAddress;
import okio.Timeout;
import serialport.SerialPortManager;
import threads.FingerprintSerialPortReadThread;
import threads.SerialPortReadThread;

/**
 * Created by Administrator on 2017/4/13.
 */
public class MyApplication extends MultiDexApplication {

    public static MyApplication instance;

    private static final String TAG = MyApplication.class.getName();

    public static boolean isLoaction = true;



    private boolean mSystembarVisible;

    @Override
    public void onCreate() {
        super.onCreate();
        this.instance = this;

//        // 全局的异常捕获
//        CrashHandler crashHandler = CrashHandler.getInstance();
//        crashHandler.init(getApplicationContext(), this);
        SerialPort serialPort;
        // 开启与单片机通信的串口安装
        if (Constants.IS_OLD_ANDROID) {
            serialPort = SerialPortManager.getSerialPort("/dev/ttyS2", 115200); //附一
        } else {
            serialPort = SerialPortManager.getSerialPort("/dev/ttyS1", 115200); // 协和
        }
        InputStream inputStream = serialPort.getInputStream();
        OutputStream outputStream = serialPort.getOutputStream();
        SerialPortReadThread serialPortReadThread = new SerialPortReadThread(inputStream, outputStream, this);
        serialPortReadThread.start();

        // 开启与指纹通信的串口
        SerialPort fingerprintSerialPort;
        if (Constants.IS_OLD_ANDROID) {
            fingerprintSerialPort = SerialPortManager.getSerialPort("/dev/ttyS1", 115200); // 附一
        } else {
            fingerprintSerialPort = SerialPortManager.getSerialPort("/dev/ttyS3", 115200);  // 协和

        }
        InputStream fingerprintInputStream = fingerprintSerialPort.getInputStream();
        OutputStream fingerprintOutputStream = fingerprintSerialPort.getOutputStream();
        FingerprintSerialPortReadThread fingerprintThread = new FingerprintSerialPortReadThread(fingerprintInputStream, fingerprintOutputStream, this);
        fingerprintThread.start();
    }

}
